<?php
/**
 * @auther:周卫星
 * @className:LoginController.php
 * @projectName:train
 * @classDesc:
 * @date:2019/10/31
 * @time:10:05
 */

namespace App\Http\Controllers\biz;


use App\Comment\Comment;
use App\Http\Controllers\Controller;
use App\Model\BizMember;
use Illuminate\Http\Request;

class LoginController extends Controller
{
    public $model;
    public function __construct()
    {
        $this -> model = new BizMember();
    }

    /**
     * 登录
     * @param Request $request
     */
    public function login(Request $request)
    {
        if ($request -> isMethod('get')){
            return view('biz.login.login');
        }
        if ($request -> isMethod('post')){
            // 获取登录的用户名
            $biz_name = $request -> post('biz_name');
            // 获取登录的密码
            $biz_pwd = $request -> post('biz_pwd');
            if ($this -> model -> login($biz_name, $biz_pwd)){
                $result = [
                    'code' => 0,
                    'msg' => '登录成功',
                    'data' => []
                ];
            }else{
                $result = [
                    'code' => 1,
                    'msg' => '登录失败',
                    'data' => []
                ];
            }
            return $this -> returnJson($result);
        }
    }

    /**
     * 退出
     * @param Request $request
     */
    public function signOut(Request $request)
    {
        if ($request -> isMethod('get')){

        }
    }
}
